/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2022-10-12 16:45:02
 * @LastEditors: sueRimn
 * @LastEditTime: 2023-02-22 15:15:16
 */

//全局混入 主要用于请求数据处理
export default {
  props: {
    originObj: {
      type: Object,
      default: () => ({
        validator: {}
      })
    },
    originElement: {
      type: Array,
      default: () => ([])
    }
  },
  data() {
    return {}
  },
  computed: {
    modelObj() {
      console.log("originObj is ", this.originObj);
      return this.originObj;
    },
    structure() {
      this.collectVariable(this.originElement);
      console.log("structure is ", this.originElement);
      return this.originElement || [];
    }
  },
  methods: {
    //收集页面表单中的变量 请求收集处理暂时缺少
    collectVariable(rows) {
      rows.forEach(row => {
        row.cols.forEach(col => {
          if (col.elements) {
            col.elements.forEach(ele => {
              if (ele.model) {
                this.$set(this.originObj, ele.name, ele[ele.name]);
                this.$set(this.originObj, ele.name, ele[ele.name]);
                if (ele.validator) {
                  this.$set(this.originObj.validator, ele.name, ele.validator)
                }
              }
            })
          } else if (col.rows) {
            this.collectVariable(col.rows)
          }
        })
      });
    }
  }
}